/**
 * Created by liubin on 2015/08/27.
 */
var webpack = require('webpack');
var path = require('path');

module.exports = {
    entry: {
        'app': path.resolve(__dirname, 'app/js/app.js'),
        'vendor': path.resolve(__dirname, 'app/js/vendor.js')}
    ,
    output: {
        path: path.resolve(__dirname, 'project/static'),
        filename: '[name].js',
        publicPath: '/static/'
    },
    resolve: {
        // 文件后缀
        extensions: ['', '.js', '.jsx']
    },
    module: {
        loaders:[
            {
                test: /\.jsx?$/, // 用正则来匹配文件路径，这段意思是匹配 js 或者 jsx
                loader: 'babel?stage=0&optional=runtime' // 加载模块 "babel" 是 "babel-loader" 的缩写
            },
            {
                test: /\.css$/, // Only .css files
                loader: 'style!css' // Run both loaders
            },
            {
                test: /\.less$/,
                loader: 'style!css!less'
            },
            {
                test: /\.(png|jpg)$/,
                //loader: 'url?limit=25000'
                loader: 'file-loader'
            },
            {
                test: /\.(ttf|eot|svg|woff(2)?)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                //loader: 'url?limit=100000'
                loader: 'file-loader'
            }
        ]
    },
    node: {
        net: 'empty',
        dns: 'empty',
        crypto: 'empty'
    },
    plugins: [
      //new webpack.ProvidePlugin({
      //  'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
      //}),
      new webpack.optimize.CommonsChunkPlugin("common.js")
    ],
    devtool: 'inline-source-map'
};